/**
* @Title: grading_ctrl.js
* @Description: TODO
* Copyright: Copyright (c) 2014 
 * Company:中国平安
*
* @Project HIMS-FWA
* @author EX-XIEQI001
* @date 2014年10月29日 下午2:22:48
* @version V1.0
*/
;
(function(){
	'use strict';
	var app = angular.module('fwa.mainApp');
	app.controller('EvaluationRuleCtrl', ['$scope','$state','$modal','BaseURL','Modal',
	                                function(scope,$state,$modal,baseUrl,Modal){
	
		//tabs集合
		scope.tabs =[
		             {"name": "定点机构考评规则","currentTab": "1"},
		             {"name": "定点药店考评规则","currentTab": "2"}
		             ];
		
		
		var orgRule = "evaluationRule.orgRule";
		var drugstore = "evaluationRule.drugstore";
		
		
		
		//点击tab事件
		scope.tabClick = function(data) {
			scope.currentTab = data.currentTab;
			queryGradingData();
		}
		
		//
		function  queryGradingData (){
			if (scope.currentTab == 1) {
				$state.go(orgRule);
			}
			else if (scope.currentTab == 2) {
				$state.go(drugstore);
			}else{
				$state.go(orgRule);
			}
		}
		
		function selectedTab() {
			if($state.current.name 
			   && $state.current.name === orgRule) {
				//选中当前tab
				scope.currentTab = scope.tabs[0].currentTab;	
			}
			else if ($state.current.name 
					   && $state.current.name === drugstore) {
				//选中当前tab
				scope.currentTab = scope.tabs[1].currentTab;
			}
			else {
				//选中当前tab
				scope.currentTab = scope.tabs[0].currentTab;
			}
			queryGradingData();
		}
		
		selectedTab();
		
		
		
		
		
	}]);
})();